<?php

class Admin_Form_StoreAdd extends Zend_Form {

    public function init() {
        $this->setMethod("post");

        #store name
        $name = new Zend_Form_Element_Text('name');
        $name->setLabel("Store Name:")
                ->setRequired(true)
                ->setAttribs(array('placeholder' => 'Enter Store Name', 'required' => 'required', 'class' => 'span12'))
                ->addFilter("StringTrim");

        #address line 1
        $address1 = new Zend_Form_Element_Text('address1');
        $address1->setLabel("Address Line 1:")
                ->setAttribs(array('placeholder' => 'Address Line 1', 'class' => 'span12', 'required' => 'required'))
                ->setRequired(true)
                ->addFilter("StringTrim");

        #address line 2
        $address2 = new Zend_Form_Element_Text('address2');
        $address2->setLabel("Address Line 2:")
                ->setAttribs(array('placeholder' => 'Address Line 2', 'class' => 'span12'))
                ->addFilter("StringTrim");


        #email address
        $email = new Zend_Form_Element_Text('email');
        $email->setLabel("Email Address")
                ->setAttribs(array('placeholder' => 'Store Email Address', 'required' => 'required', 'class' => 'span12'))
                ->addValidator("EmailAddress");


        #contact 1
        $contact1 = new Zend_Form_Element_Text('contact1');
        $contact1->setLabel("Contact [Primary]")
                ->setRequired(true)
                ->setAttribs(array('placeholder' => 'Enter Primary contact', 'class' => 'span12', 'required' => 'required'))
                ->addFilter("StringTrim");

        #contact 2
        $contact2 = new Zend_Form_Element_Text('contact2');
        $contact2->setLabel("Another Contact")
                ->setAttribs(array('placeholder' => 'Enter another contact', 'class' => 'span12'))
                ->addFilter("StringTrim");

        #state
        $state = new Zend_Form_Element_Select('state');
        $state->setLabel("Select State:")
                ->setRequired(true)
                ->setRegisterInArrayValidator(false)
                ->setAttribs(array('class' => 'span12', 'required' => 'required'));

        #city
        $city = new Zend_Form_Element_Select('city');
        $city->setLabel("Select City:")
                ->setRequired(true)
                ->setRegisterInArrayValidator(false)
                ->setAttribs(array('class' => 'span12', 'required' => 'required'));
        #zip
        $zip = new Zend_Form_Element_Select('zip');
        $zip->setLabel("Select Pincode:")
                ->setRequired(true)
                ->setRegisterInArrayValidator(false)
                ->setAttribs(array('class' => 'span12', 'required' => 'required'));

//        #select zip,city,state
//        $zipDb = new Admin_Model_Zipcode();
//        $allZipWithCityArray = $zipDb->getAllZipWithCityArray();
//        $location = new Zend_Form_Element_Select('location');
//        $location->setLabel("Select Location:")
//                ->setAttribs(array('class' => 'span12', 'required' => 'required'))
//                ->setRequired(true);
//        foreach ($allZipWithCityArray as $array) {
//            $location->addMultiOption($array['zipcode']['id'], $array['zipcode']['code'] . ", " . $array['city']['name'] . ", " . $array['state']['name']);
//        }
        #brands
        $brandDb = new Admin_Model_Brand();
        $fetchAll = $brandDb->fetchAll();
        $brands = new Zend_Form_Element_Multiselect('brands');
        $brands->setLabel("Select Brands for this store")
                ->setAttribs(array('class' => 'span12', 'required' => 'required'))
                ->setRequired(true);
        foreach ($fetchAll as $brandValue) {
            $brands->addMultiOption($brandValue->id, $brandValue->name);
        }

        #map
        $map = new Zend_Form_Element_Textarea('map');
        $map->setLabel("Enter Map Link")
                ->addFilter("StringTrim")
                ->setAttribs(array('class' => 'span12'))
                ->setOptions(array('placeholder' => 'Enter Google Map Embeded Code', 'cols' => '40', 'rows' => '4'));

        #id
        $id = new Zend_Form_Element_Hidden('id');
        $id->setValue(0);


        #submit
        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setLabel("Create Store")
                ->setAttribs(array('class' => 'btn btn-success'));

        #
        $this->addElements(array($name, $address1, $address2, $email, $contact1, $contact2, $state, $city, $zip, $brands, $map, $id, $submit));
    }

}

